473,419 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Double drop down menue

250 100+
I want to use two drop down menus in my php application. All data should select from the database(Mysql) . Eg: 1st drop down(Fruit,Country,game) after selecting a item from the first drop down , second one should load perticular data from tha database. If i select Fruit then automatically load Mango,banana.etc to the second drop down. Could you please help me?
Mar 25 '08 #1
5 3575
ronverdonk
4,258 Expert 4TB
We are here to help programmers with their PHP problems. And we can only help when we can see and work on the code you have developed.

So show it here and do not forget to enclose any code within the appropriate code tags!

Ronald
Mar 25 '08 #2
ghjk
250 100+
We are here to help programmers with their PHP problems. And we can only help when we can see and work on the code you have developed.

So show it here and do not forget to enclose any code within the appropriate code tags!

Ronald

This is my first dropdown(Thease are hard coded. no need to select from the database)
[HTML]<select name="name" id="name" >
<option value="Select" selected="selected">Select</option>
<option value="Fruit" >Fruit</option>
<option value="Country" >Country</option>
<option value="Game"> Game</option>
</select> [/HTML]

And second drop down should filled depend on the selected value in first dropdown.(get values from mysql database)
Mar 26 '08 #3
Expand|Select|Wrap|Line Numbers
  1. <!--
  2. ----------------------------
  3. here i juz worked in a localhost.
  4. database: demo1;
  5. table: demo_table;
  6. fields(demo_table)
  7.     item varchar(20);
  8.     list varchar(20);
  9. example table data( i here used a simple table structure u can use a well one):
  10. item    list
  11. fruit     Mango
  12. fruit     banana
  13. Country   India
  14. Country   USA
  15. Country   UK
  16. ----------------------------
  17. -->
  18. <html>
  19. <head>
  20. <title></title>
  21. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  22. <script type="text/javascript">
  23. function getItem(sel)
  24. {
  25.     var itemCode = sel.options[sel.selectedIndex].value;
  26.     //alert(itemCode);
  27.      var url= "http://localhost/onchange1.php?item="+itemCode;
  28. window.location=url;
  29.  
  30. }
  31. </script>
  32. </head>
  33.  
  34. <body>
  35.  
  36. <form action="" method="post">
  37. <table>
  38.     <tr>
  39.         <td>Item </td>
  40.         <td><select id="item" name="item" onchange="getItem(this)">
  41.             <option value="">Select </option>
  42.             <option value="Fruit">Fruit</option>
  43.             <option value="Country" >Country</option>
  44.                 </select>
  45.         </td>
  46.     </tr>
  47.     <tr>
  48.         <td>List </td>
  49.         <td><select id="item_list" name="item_list"  >
  50.         <option value="">Select </option>
  51.         <?php
  52. $i_code=$_REQUEST['item'];
  53.  
  54. $con = mysql_connect("localhost","root","");
  55. mysql_select_db("demo1",$con);
  56.  
  57. $query="select list from demo_table where item='$i_code'";
  58. $res=mysql_query($query);
  59. $num=mysql_num_rows($res);
  60. for($i=0;$i<$num;$i++)
  61. {
  62. $data=mysql_fetch_array($res);
  63. $v=$data[0].$i;
  64.  echo "<option value='$data[0]'>".$data[0]."</option>";
  65. }
  66. ?>
  67. </select>
  68. </td>
  69. </tr>
  70. </table>
  71. </form>
  72. </body>
  73. </html>
  74.  
it is a simplest method, and also u can use AJAX.
Apr 5 '08 #4
Atli
5,058 Expert 4TB
Hi sethupnr.

Please use [code] tags when posting your code examples. (See How to ask a question)

[code=html] ...HTML code goes here... [/code]

Thank you.
Apr 5 '08 #5
i have categories,then under each category,i want a sub category,all from database for example,category sells,then sub items and this is a menue in an html page from database,can u help plz
Nov 5 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
1
by: objectref | last post by:
Hi to all, i have an app that i allow a drag and drop operation of picture boxes on a panel. when i drop a picture box i do the following so my newly dropped picture box will be able to...
1
by: Axel Gillert | last post by:
Hi! I search a way (in c#) to integrate my own application into the Windows-Desktop-Kontext-Menue (like ATI Hydravision, Catalyst Controlcenter ....), so that a user can start it by clicking...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
29
by: Gregc. | last post by:
G'day I was wondering if someone can explain the concept of 'returning a Char from a Double' . For example, I have the following code: char getGrade(double mark) { if (mark>= 85) return...
3
by: ssoffline | last post by:
hi i have an app in which i can drop objects onto a form and move them, it consists of graphics (lines), i am using double buffering to avoid filckering in the parent control which is a panel,but...
1
by: Bobc003 | last post by:
Hi, I'd like to put a double drop-down menu on my webpage and instead of a redirection to a new webpage, I'd like to display the result in a new section. I'm kind of stuck and I only have a triple...
0
by: geoman | last post by:
Hello, Anyone know of and example that does this? Drop down 1 Select category Apples Peach Drop down 2 populated from 1 Apple pie
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.